<template>
  <div style="background-color: #fffb6f">
    <h1>主页</h1>
    <el-table>
      <el-table-column prop="date" label="日期" width="140">
      </el-table-column>
      <el-table-column prop="name" label="姓名" width="120">
      </el-table-column>
      <el-table-column prop="address" label="地址">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
    import store from "../vuex/store";
    import router from "../router";

    export default {
        name: "Main",
        //钩子函数，进入路由之前要将查看登录信息是否仍在，防止因为刷新页面（关掉页面就丢失
        beforeRouteEnter: (to, from, next) => {
          if (store.state.loginName === ""){
            if (sessionStorage.getItem("memoryId") === null){
              router.push('/Login');
              alert("请先登录");
            }
            store.commit("increment",sessionStorage.getItem("memoryId"));
          }
          next();
        },
    }
</script>

<style scoped>

</style>
